package com.spddr.pmos.jpa;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.joda.time.LocalDate;

import cn.seqdata.jpa.AbstractPersistable;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;

@Entity
@Table(name = "customer_credit")
public class CustomerCredit extends AbstractPersistable<CustomerEvalId> {
	private static final long serialVersionUID = 1L;

	private Customer customer;

	public CustomerCredit() {
	}

	public CustomerCredit(LocalDate date, long customer) {
		setId(new CustomerEvalId(date, customer));
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "customer", nullable = false, insertable = false, updatable = false)
	@JsonSerialize(using = cn.seqdata.jackson.ObjectSerializer.IdName.class)
	public Customer getCustomer() {
		return this.customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}
}